package com.cebbank.yyi.springbootapp.jingtang.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum DocStatusEnum {
    RUNNING("3", "RUNNING", "执行"),
    PREPARATION("", "PREPARATION", "编制中"),
    APPROVED("", "APPROVED", "审批中"),
    WAIT_APPROVE("", "WAIT_APPROVE", "待发布"),
    REVIEW("", "REVIEW", "评审中"),
    REPEALED("5", "REPEALED", "废止");

    /**
     * 老系统对应的类型
     */
    private final String oldId;

    private final String name;

    private final String displayName;

    public static DocStatusEnum getDocStatusEnum(String oldId) throws Exception {
        for (DocStatusEnum docStatusEnum : DocStatusEnum.values()) {
            if (docStatusEnum.getOldId().equals(oldId)) {
                return docStatusEnum;
            }
        }
        throw new Exception("DocStatusEnum：老系统ID映射失败，当前OLD_ID为：" + oldId);
    }

    public static DocStatusEnum containsDisplayName(String displayName) {
        for (DocStatusEnum docStatusEnum : DocStatusEnum.values()) {
            if (displayName.contains(docStatusEnum.getDisplayName())) {
                return docStatusEnum;
            }
        }
        return null;
    }
}
